import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

import tuiRate from "@/components/rate/rate"
import button from "@/components/button/button"
import loadmore from '@/components/loadmore/loadmore.vue';
import nomore from '@/components/nomore/nomore.vue';
Vue.component('tui-rate', tuiRate);
Vue.component('tui-button', button);
Vue.component('loadmore', loadmore);
Vue.component('nomore', nomore);


import * as Api from './config/api.js';
import * as Common from './config/common.js';
import * as Db from './config/db.js';
import * as Config from './config/config.js';
import store from './store'

Vue.prototype.$api = Api;
Vue.prototype.$common = Common;
Vue.prototype.$db = Db;
Vue.prototype.$config = Config;
Vue.prototype.$store = store;

App.mpType = 'app'

function fnFormatDate(time) {
	var ago, curTime, diff, int;
	time=new Date(time)
	time -= 0;
	if (("" + time).length === 10) {
		time *= 1000;
	}
	int = parseInt;
	curTime = +new Date();
	diff = curTime - time;
	ago = "";
	if (1000 * 60 > diff) {
		ago = "刚刚";
	} else if (1000 * 60 <= diff && 1000 * 60 * 60 > diff) {
		ago = int(diff / (1000 * 60)) + "分钟前";
	} else if (1000 * 60 * 60 <= diff && 1000 * 60 * 60 * 24 > diff) {
		ago = int(diff / (1000 * 60 * 60)) + "小时前";
	} else if (1000 * 60 * 60 * 24 <= diff && 1000 * 60 * 60 * 24 * 30 > diff) {
		ago = int(diff / (1000 * 60 * 60 * 24)) + "天前";
	} else if (1000 * 60 * 60 * 24 * 30 <= diff && 1000 * 60 * 60 * 24 * 30 * 12 > diff) {
		ago = int(diff / (1000 * 60 * 60 * 24 * 30)) + "月前";
	} else {
		ago = int(diff / (1000 * 60 * 60 * 24 * 30 * 12)) + "年前";
	}
	return ago;
}
Vue.filter('fnFormatDate', fnFormatDate)

const app = new Vue({
	...App
})
app.$mount()
